package com.geeklei.media.ui.utils;

import java.text.SimpleDateFormat;
import java.util.Formatter;
import java.util.Locale;

public class DKTimeFormatter {
    public static final int DEFAULT_IMG_SHOW_DURATION = 1000;
    private static DKTimeFormatter instance = new DKTimeFormatter();
    private StringBuilder mFormatBuilder = new StringBuilder();
    private Formatter mFormatter = new Formatter(this.mFormatBuilder, Locale.getDefault());

    private DKTimeFormatter() {
    }

    public static DKTimeFormatter getInstance() {
        return instance;
    }

    public String stringForTime(int i) {
        int i2 = i / DEFAULT_IMG_SHOW_DURATION;
        int i3 = i2 % 60;
        int i4 = (i2 / 60) % 60;
        i2 /= 3600;
        this.mFormatBuilder.setLength(0);
        if (i2 > 0) {
            return this.mFormatter.format("%02d:%02d:%02d", new Object[]{Integer.valueOf(i2), Integer.valueOf(i4), Integer.valueOf(i3)}).toString();
        }
        return this.mFormatter.format("%02d:%02d", new Object[]{Integer.valueOf(i4), Integer.valueOf(i3)}).toString();
    }

    public int getHoursForTime(int i) {
        return (i / DEFAULT_IMG_SHOW_DURATION) / 3600;
    }

    public int getMinutesForTime(int i) {
        return ((i / DEFAULT_IMG_SHOW_DURATION) / 60) % 60;
    }

    public int getSecondsForTime(int i) {
        return (i / DEFAULT_IMG_SHOW_DURATION) % 60;
    }

    public String longToDate(long j) {
        return new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(Long.valueOf(j));
    }

    public String longToDayDate(long j) {
        return new SimpleDateFormat("yyyy-MM-dd").format(Long.valueOf(j));
    }

    /**
     * 转换时间
     *
     * @param sec 毫秒 值
     * @return 09:20
     */
    public String getTimeStr(int sec) {
        int second = sec / 1000;
        int hh = second / 3600;
        int mm = second % 3600 / 60;
        int ss = second % 60;
        String strTemp = "";
        if (0 != hh) {
            strTemp = String.format(Locale.CHINA, "%02d:%02d:%02d", hh, mm, ss);
        } else {
            strTemp = String.format(Locale.CHINA, "%02d:%02d", mm, ss);
        }
        return strTemp;
    }
}
